package com.cx.bank.vo;

/**
 * @author jxau_scf
 * @date 2021/8/5 - 9:35
 */
public enum UserTypeEnum {
    ORDINARY_USER("00","普通用户"),
    ADMIN_USER("01", "管理员")
    ;

    private String code;
    private String userMessage;

    UserTypeEnum(String code, String userMessage) {
        this.code = code;
        this.userMessage = userMessage;
    }

    public String getCode() {
        return code;
    }

    public String getUserMessage() {
        return userMessage;
    }

    /**
     * 根据code和userMessage 获得枚举实例
     * @param code
     * @param userMessage
     * @return
     */
    public static UserTypeEnum match(String code, String userMessage){
        UserTypeEnum[] enums = UserTypeEnum.values();
        for (UserTypeEnum userTypeEnum : enums){
            if (code.equals(userTypeEnum.getCode()) && userMessage.equals(userTypeEnum.getUserMessage())){
                return userTypeEnum;
            }
        }
        return null;
    }
}
